<template>
  <el-container>
    <el-header class="header">
      <header-bar :googleEmail="googleEmail"></header-bar>
    </el-header>
    <el-container>
      <el-container>
        <el-main>
          <el-card><slot name="body"></slot></el-card>
        </el-main>
        <el-footer>
          <footer-bar></footer-bar>
        </el-footer>
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
  import HeaderBar from './Header'
  import FooterBar from './Foot'
  import {api, getRequest} from "@/api/commit"
  export default {
    name: "layout",
    components:{
      HeaderBar,
      FooterBar
    },
    data(){
      return{
        isLogin:true,
        googleEmail:"",
      }
    },
    created(){
      // google登录，返回401
      getRequest(api['check_login']).then((res) => {
        res = res.resultReturn
        this.isLogin = true
        this.googleEmail = res.data.operator_email
      },(error) => {
          console.error(error)
          this.isLogin = false
          this.googleEmail = ""
         // 重定向到登录页
         window.location.href = window.location.origin+"/"+api['google_login']+"?next="+window.location.origin;
        }
      )


    }
  }
</script>

<style scoped>
  .header{
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;
    font-weight: 400;
    font-size: 25px;
    line-height: 56px;
  }
  .el-header{
    padding: 0 0;
  }
</style>
